<?php

/**
 * Created by PhpStorm.
 * User: SwmIsMe
 * Date: 2017/6/24
 * Time: 20:28
 */
namespace app\search\controller;

use think\Controller;

class Search extends Controller
{
    //小程序
    public function index($type_id=0,$offset=0,$pagesize=4,$keyword='') {

        $lists = db('product')->where('title|detail','like',"%$keyword%")-> order('id', 'desc')->limit($offset, $pagesize)->select();
        if ($lists) {
            foreach ($lists as $k => $value) {
                $lists[$k]['detail'] = strip_tags($value['detail']);
                $lists[$k]['add_time'] = date('y-m-d', $value['add_time']);
            }
        }
        return $this->sucReturn($lists);
    }

}